<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增sys_schedul_pai')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-pai-add">
        <h4 class="form-header h4">sys_schedul_pai信息</h4>
        <div class="form-group">
            <label class="col-sm-3 control-label">排班名称：</label>
            <div class="col-sm-8">
                <input name="name" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">创建人：</label>
            <div class="col-sm-8">
                <input name="createName" class="form-control" th:value="${user.userId}" type="hidden">
                <span th:text="${user.userName}"></span>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">所属部门：</label>
            <div class="col-sm-8">
                <!--                    <input name="deptId" class="form-control" type="text">-->
                <input name="deptId" type="hidden" id="treeId"/>
                <input name="deptName" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">紧急程度：</label>
            <div class="col-sm-8">
                <select name="urgent" id="urgent" class="form-control" >
                    <option value="普通">普通</option>
                    <option value="略紧急">略紧急</option>
                    <option value="紧急">紧急</option>
                </select>
            </div>
        </div>
        <h4 class="form-header h4">排班表</h4>
        <div class="row">
            <div class="col-sm-12">
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table">
                        <tr class="active">
                            <td>开始时间</td>
                            <td>结束时间</td>
                            <td>值班人</td>
                        </tr>
                        <tr class="active">
                            <td><input name="beginTime"  type="datetime" placeholder="开始时间" class="form-control"></td>
                            <td><input name="endTime"  type="text" placeholder="结束时间" class="form-control"></td>
                            <!--                                <input class="form-control" type="text" placeholder="值班人">-->
                            <td>
                                <select name="zhiId" class="form-control">
                                    <option value=""></option>
                                    <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                                        <span th:text="*{userName}"></span>
                                    </option>
                                </select>
                            </td>
                        </tr>
                        <tr class="active">
                            <td><input name="beginTime"  type="text" placeholder="开始时间" class="form-control"></td>
                            <td><input name="endTime"  type="text" placeholder="结束时间" class="form-control"></td>
                            <!--                                <input class="form-control" type="text" placeholder="值班人">-->
                            <td>
                                <select name="zhiId"  class="form-control">
                                    <option value=""></option>
                                    <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                                        <span th:text="*{userName}"></span>
                                    </option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td><input name="beginTime"  type="text" placeholder="开始时间" class="form-control"></td>
                            <td><input name="endTime"  type="text" placeholder="结束时间" class="form-control"></td>
                            <!--                                <input class="form-control" type="text" placeholder="值班人">-->
                            <td>
                                <select name="zhiId"  class="form-control">
                                    <option value=""></option>
                                    <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                                        <span th:text="*{userName}"></span>
                                    </option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td><input name="beginTime"  type="text" placeholder="开始时间" class="form-control"></td>
                            <td><input name="endTime"  type="text" placeholder="结束时间" class="form-control"></td>
                            <!--                                <input class="form-control" type="text" placeholder="值班人">-->
                            <td>
                                <select name="zhiId"  class="form-control">
                                    <option value=""></option>
                                    <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                                        <span th:text="*{userName}"></span>
                                    </option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td><input name="beginTime"  type="datetime" placeholder="开始时间" class="form-control"></td>
                            <td><input name="endTime"  type="datetime" placeholder="结束时间" class="form-control"></td>
                            <!--                                <input class="form-control" type="text" placeholder="值班人">-->
                            <td>
                                <select name="zhiId"  class="form-control">
                                    <option value=""></option>
                                    <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                                        <span th:text="*{userName}"></span>
                                    </option>
                                </select>
                            </td>
                        </tr>

                    </table>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "system/pai"
    $("#form-pai-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-pai-add').serialize());
        }
    }

    $("input[name='endTime'],input[name='beginTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    /* 用户管理-新增-选择部门树 */
    function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        var url = ctx + "system/user/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        console.log(deptId)
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }

</script>
</body>
</html>